package com.xx.bili.controller;

import cn.hutool.json.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.json.JsonMapper;
import com.xx.bili.domain.BiLiLike;
import com.xx.bili.domain.vo.BatchLikeVO;
import com.xx.bili.domain.vo.batch.BiLiBatchLike;
import com.xx.bili.service.IBiLiLIkeService;
import com.xx.common.core.controller.BaseController;
import com.xx.common.core.domain.AjaxResult;
import com.xx.common.core.page.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 点赞下单Controller
 *
 * @author ruoyi
 * @date 2024-09-28
 */
@RestController
@RequestMapping("/bili/like")
public class BiLiLikeController extends BaseController
{
    @Autowired
    private IBiLiLIkeService biLiLikeService;

    /**
     * 查询bili点赞下单列表
     */
    @GetMapping("/list")
    public TableDataInfo list(BiLiLike biLiLike)
    {
        startPage();
        List<BiLiLike> list = biLiLikeService.selectBiLiLikeList(biLiLike);
        return getDataTable(list);
    }

    /**
     * 根据oid，rpid，操作类型获取数量
     */
    @GetMapping("/checkOidRpidLikeCount")
    public AjaxResult checkOidRpidLikeCount(BiLiLike biLiLike)
    {
        return success(biLiLikeService.checkOidRpidLikeCount(biLiLike));
    }

    /**
     * 获取点赞下单
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(biLiLikeService.selectBiLiLikeById(id));
    }

    /**
     * 根据main链接获取评价列表
     */
    @PostMapping(value = "/getReplyByMainUrl")
    public AjaxResult getReplyByMainUrl(@RequestBody BiLiBatchLike biLiBatchLike)
    {
        return success(biLiLikeService.getReplyByMainUrl(biLiBatchLike));
    }


    /**
     * 新增点赞下单
     */
    @PostMapping
    public AjaxResult add(@RequestBody BiLiLike biLiLike)
    {
        return success(biLiLikeService.insertBiLiLike(biLiLike));
    }

    @PostMapping("batchBiLiLike")
    public AjaxResult batchBiLiLike(@RequestBody BatchLikeVO batchLikeVO)
    {
        biLiLikeService.batchBiLiLike(batchLikeVO);
        return success();
    }

    /**
     * 删除点赞下单
     */
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(biLiLikeService.deleteBiLiLikeByIds(ids));
    }
}
